package com.v1.video.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class SoftKeyBoardRelativeLayout extends LinearLayout {
	
	private OnKeyBoardListener keyboradlistener;
	
	
	
	public SoftKeyBoardRelativeLayout(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
	}

	public SoftKeyBoardRelativeLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public void setOnkeyBoardListener(OnKeyBoardListener keyboardlistener){
		this.keyboradlistener = keyboardlistener;
	}
	
	private int min=0,max=0;

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		if(heightMeasureSpec>=max){
			if(max==0) 	max = heightMeasureSpec;
			if(keyboradlistener!=null) {
				keyboradlistener.onHiddenKeyBoard();
			}
		}else{
			if(min==0)	min = heightMeasureSpec;
			if(keyboradlistener!=null) {
				keyboradlistener.onShowKeyBoard(max-min);
			}
		}
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
	
	public interface OnKeyBoardListener {
		void onShowKeyBoard(int height);
		void onHiddenKeyBoard();
	}

}
